/**
 * @Project : ProgrammingExercises
 * @Package : Leetcode
 * @File : Q2490.java
 * @Author : WangRuoyu
 * @Date 2022/12/17 18:45
 */

package leetcode;

public class Q2490 {
    public boolean isCircularSentence(String sentence) {
        if (sentence.charAt(0) != sentence.charAt(sentence.length() - 1)) {
            return false;
        } else {
            for (int i = 0; i < sentence.length(); i++) {
                if (sentence.charAt(i) == ' ') {
                    if (sentence.charAt(i - 1) != sentence.charAt(i + 1)) {
                        return false;
                    }
                }
            }
            return true;
        }
    }

    public static void main(String[] args) {
        Q2490 sl = new Q2490();
        String sentence = "leetcode exercises sound delightful";
        System.out.println(sl.isCircularSentence(sentence));
    }
}
